import $axios from "@/common/http.js";//请求实例
import { Message } from "element-ui";
import router from "@/router"


export const getSecklist = async () => {
    return await $axios.get('/secklist')
}

export const getGoods = async () => {
    return await $axios.get('/goodslist')
}


export const addGoods = async (data) => {
    console.log(data);
    let rst = await $axios.post('/seckadd', data)
    if (rst.code == 200)
        Message({
            type: "success",
            message: "菜单添加成功",
            duration: 500,
            onClose() {//关闭之后，回到页面
                router.go(-1);
            }
        })
}

export const seckinfo = async (id) => {
    return await $axios.get('/seckinfo', { params: { id } })
}


export const editSeck = async (data) => {
    let rst = await $axios.post('/seckedit', data)
    if (rst.code == 200)
        Message({
            type: "success",
            message: "菜单添加成功",
            duration: 500,
            onClose() {//关闭之后，回到页面
                router.go(-1);
            }
        })
}


export const delSeck = async (id) => {
    let rst = await $axios.post('/seckdelete', { id })
    // console.log(rst);
    if (rst.code == 200) {
        Message({
            type: "success",
            message: rst.msg,
            duration: 500
        })
        return true
    } else
        return false

}